/** @file               sw_device.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of the swallow library
 *  @author             $Author: Thinkpad $
 *  @version            $Rev: 410 $
 *  @date               $Date: 2016-12-28 11:38:48 +0800 (周三, 28 12月 2016) $
 */
#ifndef __SW_DEVICE_H__
#define __SW_DEVICE_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifdef WIN32
typedef HANDLE SW_DEVICE;
#define SW_INVALID_DEVICE (SW_DEVICE)(INVALID_HANDLE_VALUE)
#else
typedef int SW_DEVICE;
#define SW_INVALID_DEVICE (SW_DEVICE)(-1)
#endif

SW_API SW_RET SW_InitDeviceAPI(SW_VOID);
SW_API SW_RET SW_RunDeviceAPI(SW_VOID);
SW_API SW_RET SW_StopDeviceAPI(SW_VOID);
SW_API SW_RET SW_ExitDeviceAPI(SW_VOID);
SW_API SW_DEVICE SW_OpenDevice(const SW_CHAR *pDevName, SW_BOOL nonBlock);
SW_API SW_DEVICE SW_OpenDeviceEx(const SW_CHAR *pDevName, SW_OPEN_FLAG openFlag, SW_BOOL nonBlock, SW_UINT32 mode, SW_BOOL sync);
SW_API SW_RET SW_CloseDevice(SW_DEVICE dd);
SW_API SW_RET SW_SetDeviceAsyncProc(SW_DEVICE dd, SW_SIGNAL_PROC proc);
SW_API SW_UINT32 SW_ReadDevice(SW_DEVICE dd, SW_VOID *pBuf, SW_UINT32 bufLen);
SW_API SW_UINT32 SW_WriteDevice(SW_DEVICE dd, const SW_VOID *pBuf, SW_UINT32 bufLen);
SW_API SW_RET SW_DeviceIoctl(SW_DEVICE dd, SW_UINT32 cmd, SW_VOID *pArg, SW_INT32 *pRet);

#ifdef __cplusplus
}
#endif

#endif

